package com.demo.common.tool;

import java.text.SimpleDateFormat;
import java.util.Date;

public class ToolTime {

	private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
	
	/**
	 * 根据默认格式获取当前时间
	 * */
	public static String getNowTimeStr() {
		return getNowTimeStr(DATE_FORMAT);
	}
	
	/**
	 * 根据指定格式获取当前时间
	 * */
	public static String getNowTimeStr(String dateFormet){
		SimpleDateFormat sdf = new SimpleDateFormat(dateFormet);
		return sdf.format(new Date());
	}
	
	public static int getIntervalMinute(Date time1, Date time2) {
		return Math.abs((int)(time1.getTime() - time2.getTime())/(1000*60));
	}
}
